package com.xkstream.client.nim;

import com.xkstream.client.nim.CustomAttachment;
import com.xkstream.client.nim.CustomAttachmentType;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by xiaoyi on 2017/8/23.
 */

public class WinAttachment extends CustomAttachment {
    WinAttachment() {
        super(CustomAttachmentType.Win);
    }

    private boolean isRobot;
    private int profit;
    private String anchorNickName;
    private String currency;
    private String userNickName;

    public boolean isRobot() {
        return isRobot;
    }

    public void setRobot(boolean robot) {
        isRobot = robot;
    }

    public int getProfit() {
        return profit;
    }

    public void setProfit(int profit) {
        this.profit = profit;
    }

    public String getAnchorNickName() {
        return anchorNickName;
    }

    public void setAnchorNickName(String anchorNickName) {
        this.anchorNickName = anchorNickName;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getUserNickName() {
        return userNickName;
    }

    public void setUserNickName(String userNickName) {
        this.userNickName = userNickName;
    }

    @Override
    public void parseData(String str) {
        try {

            JSONObject jsonObj = new JSONObject(str);
            if(jsonObj.has("isRobot")){
                isRobot = jsonObj.getBoolean("isRobot");
            }
            if(jsonObj.has("profit")){
                profit = jsonObj.getInt("profit");
            }
            if(jsonObj.has("anchorNickName")){
                anchorNickName = jsonObj.getString("anchorNickName");
            }
            if(jsonObj.has("currency")){
                currency = jsonObj.getString("currency");
            }
            if(jsonObj.has("userNickName")){
                userNickName = jsonObj.getString("userNickName");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public JSONObject packData() {
        return null;
    }
}
